﻿@model WI.CandidateManager.Common.Data.Entities.SingleQuestion
@using WI.CandidateManager.Common.Data.Enums

@{
    ViewBag.Title = @Resources.Common.CommonQuestionEdit;
}

<h2>@Resources.Common.CommonQuestionEdit</h2>

@using (Html.BeginForm("EditQuestion", "Tests", new { @QuestionId = Model.Id }, FormMethod.Post))
{
    @Html.ValidationSummary(true)

    <table class="bordered">
        <tr>
            <td class="vertical-header">@Html.LabelFor(model => model.Text)</td>
            <td>@Html.TextAreaFor(model => model.Text, new { @class = "" })</td>
        </tr>
    </table>
  
    <h3>@Resources.Common.CommonAnswerList</h3>
    
    <p>@Html.ActionLink(@Resources.Common.CommonButtonCreateSingleAnswer, "CreateSingleAnswer", new { @QuestionId = Model.Id }, new { @class = "common-btn BlueColor" }) @Html.ActionLink(@Resources.Common.CommonButtonCreateFreeText, "CreateFreeTextAnswer", new { @QuestionId = Model.Id }, new { @class = "common-btn BlueColor" })</p>
   
    <table class="bordered">
        <thead>
            <tr>
                <th>@Resources.Common.CommonButtonEdit</th>
                <th>@Resources.Common.CommonColumnAnswerText</th>
                <th>@Resources.Common.CommonColumnIsCorrect</th>
                <th>@Resources.Common.CommonButtonDelete</th>
            </tr>
        </thead>

        @foreach (var answer in Model.AnswerBase)
        {
            if (answer.State == State.Active)
            {
            <tr>
                <td class="Center column-detail">@Html.ActionLink(@Resources.Common.CommonButtonEdit, "EditAnswer", new { @AnswerId = answer.Id }, new { @class = "common-btn BlueColor" })</td>
                <td>@answer.Text</td>
                <td>@answer.IsCorrect</td>
                <td class="Center column-delete">@Html.ActionLink(@Resources.Common.CommonButtonDelete, "DeleteAnswer", new { @AnswerId = answer.Id }, new { @class = "common-btn RedColor" })</td>
            </tr>
            }
        }
    </table>

    <p>
        @Html.ActionLink(@Resources.Common.CommonButtonCancel, "Edit", new { @TestId = Model.Test.Id }, new { @class = "common-btn-large BlueColor" })
        <input class="common-btn-large BlueColor" type="submit" value=@Resources.Common.CommonButtonSave />
    </p>
}